<?php
/**
 * Created by PhpStorm.
 * User: xiaofeng
 * motto: 现在的努力是为了小时候吹过的牛逼！
 * Date: 2020/2/15
 * Time: 22:10
 */
namespace  app\api\controller;

use app\BaseController;
use app\common\business\Sms as SmsBus;
class Sms extends BaseController {

    public function code():object {

        $phoneNumber = input('param.phone_number','','trim');
        $data = [
            'phone_number'=>$phoneNumber
        ];
       try{
            validate(\app\api\validate\User::class)->scene("send_code")->check($data);
       }catch (\think\Exception\ValidateException $e){
           return show(config("status.error"),$e->getError());
       }
       //调用business层
        if (SmsBus::sendCode($phoneNumber,6,'ali')){
            return show(config("status.success"),'发送验证码成功');
        }
        return show(config("status.error"),'发送验证码失败');

    }
}
